#!/bin/bash

# 区域管理模块Redis缓存清除脚本
# 作者: Wu.Liang
# 日期: 2024-12-21

echo "开始清除区域管理模块Redis缓存..."

# Redis连接信息
REDIS_HOST="127.0.0.1"
REDIS_PORT="6379"
REDIS_PASSWORD=""

# 清除区域管理模块相关的缓存key
echo "清除Building相关缓存..."
redis-cli -h $REDIS_HOST -p $REDIS_PORT KEYS "building:*" | xargs -r redis-cli -h $REDIS_HOST -p $REDIS_PORT DEL

echo "清除Region相关缓存..."
redis-cli -h $REDIS_HOST -p $REDIS_PORT KEYS "region:*" | xargs -r redis-cli -h $REDIS_HOST -p $REDIS_PORT DEL

echo "清除Community相关缓存..."
redis-cli -h $REDIS_HOST -p $REDIS_PORT KEYS "community:*" | xargs -r redis-cli -h $REDIS_HOST -p $REDIS_PORT DEL

echo "清除Unit相关缓存..."
redis-cli -h $REDIS_HOST -p $REDIS_PORT KEYS "unit:*" | xargs -r redis-cli -h $REDIS_HOST -p $REDIS_PORT DEL

echo "清除Household相关缓存..."
redis-cli -h $REDIS_HOST -p $REDIS_PORT KEYS "household:*" | xargs -r redis-cli -h $REDIS_HOST -p $REDIS_PORT DEL

echo "清除RegionStats相关缓存..."
redis-cli -h $REDIS_HOST -p $REDIS_PORT KEYS "region_stats:*" | xargs -r redis-cli -h $REDIS_HOST -p $REDIS_PORT DEL

echo "区域管理模块Redis缓存清除完成！"

# 显示剩余的缓存key数量
echo "当前Redis中的key数量:"
redis-cli -h $REDIS_HOST -p $REDIS_PORT DBSIZE 